package com.mage.servlet;

import com.mage.bean.User;
import com.mage.dao.ChongzhiDao;
import com.mage.dao.UserDao;
import com.mage.dao.impl.ChongzhiDaoImpl;
import com.mage.dao.impl.UserDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/SuperVipTuifeiServlet")
public class SuperVipTuifeiServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    public SuperVipTuifeiServlet() {
        super();
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            //1. 接收id
            int userid = Integer.parseInt(request.getParameter("userid"));


            UserDao userservice = new UserDaoImpl();
            User user = userservice.findUserById(userid);
            user.setMoney(0);
            user.setWxf(0);
            userservice.update(user);
            //3. 跳转到列表页。
            request.getRequestDispatcher("UserListServlet").forward(request, response);
        }catch (Exception e) {
        }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }


}
